package com.sky.mapper;

import com.sky.dto.SetmealDTO;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {

    @Select("select count(1) from setmeal where category_id = #{id}")
    int selectCate(Long id);
//套餐分页查询
    //查询符合条件的总套餐数量
    int selectCount(Setmeal setmeal);
    //查询符合条件的套餐
    List<Setmeal> select(@Param("setmeal") Setmeal setmeal, @Param("start") int start, @Param("end") int end);
    List<Setmeal> list(Setmeal setmeal);
//添加套餐
    @Insert("insert into setmeal (id, category_id, name, price, status, description, image, create_time, update_time, create_user, update_user) values " +
            "(#{id},#{categoryId},#{name},#{price},#{status},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void addSetmeal(Setmeal setmeal);
    //查询套餐id
    @Select("select id from setmeal where name = #{name}")
    Long selectByname(String name);
//删除套餐
    @Delete("delete from setmeal where id = #{id}")
    void deleteSmeal(Long id);
//根据id查询套餐
    @Select("select * from setmeal where id = #{id}")
    Setmeal selectById(Long id);
//套餐启停
    @Update("update setmeal set status = #{status} where id = #{id}")
    void sos(Integer id, String status);
//根据id查询菜品选项
    @Select("select sd.name, sd.copies, d.image, d.description " +
            "from setmeal_dish sd left join dish d on sd.dish_id = d.id " +
            "where sd.setmeal_id = #{setmealId}")
    List<DishItemVO> getDishItemBySetmealId(Long setmealId);
//查询套餐数量
    Integer countByMap(Map map);
}
